package day4;

public class Test3 {
    //可变参数求和
    public static int getSum(int... arr){
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }
        return sum;
    }

    public static void main(String[] args) {

        //几个参数
        int result = getSum(2,4,5);
        System.out.println(result);
        //无参数
        int result1 = getSum();
        System.out.println(result1);
        //数组
        int[] arr = {2,4,5};
        int result2 = getSum(arr);
        System.out.println(result2);

    }
}
